﻿#region

using System;
using EsbMonitorExtension.MonitorTasks.Base;
using EsbMonitorMessages.Events;
using log4net;
using NServiceBus.Unicast;

#endregion

namespace EsbMonitorExtension.MonitorTasks
{
    public class ServiceStartedTask : BaseMonitorTask
    {
        private static readonly ILog Logger = LogManager.GetLogger(typeof (ServiceStartedTask));

        public ServiceStartedTask(IUnicastBus bus)
            : base(bus)
        {
        }

        public override void RunTask()
        {
            Logger.Info("Running ServiceStartedTask");

            Bus.Send<IServiceStarted>(e =>
                                          {
                                              e.ServiceInfo = Bus.ServiceInfo();
                                              e.EventTime = DateTime.Now;
                                          });
           
            Logger.Info("Finished ServiceStartedTask");
        }
    }
}